import type { ApiEndpoint, DataTable, GenerateConfig } from "../types"

/** 模拟数据表 */
export const mockTables: DataTable[] = [
  {
    id: "users",
    name: "users",
    comment: "用户表",
    createdAt: "2025-01-01 10:00:00",
    updatedAt: "2025-01-15 14:30:00",
    fields: [
      {
        id: "id",
        name: "id",
        type: "number",
        required: true,
        isPrimary: true,
        autoIncrement: true,
        comment: "用户ID"
      },
      {
        id: "username",
        name: "username",
        type: "string",
        length: 50,
        required: true,
        isPrimary: false,
        autoIncrement: false,
        comment: "用户名"
      },
      {
        id: "email",
        name: "email",
        type: "string",
        length: 100,
        required: true,
        isPrimary: false,
        autoIncrement: false,
        comment: "邮箱"
      },
      {
        id: "phone",
        name: "phone",
        type: "string",
        length: 20,
        required: false,
        isPrimary: false,
        autoIncrement: false,
        comment: "手机号"
      },
      {
        id: "department_id",
        name: "department_id",
        type: "number",
        required: false,
        isPrimary: false,
        autoIncrement: false,
        comment: "部门ID",
        relation: {
          targetTableId: "departments",
          targetTableName: "departments",
          targetFieldId: "id",
          targetFieldName: "id",
          type: "many-to-one",
          enabled: true
        }
      },
      {
        id: "status",
        name: "status",
        type: "boolean",
        required: true,
        isPrimary: false,
        autoIncrement: false,
        defaultValue: "true",
        comment: "用户状态"
      },
      {
        id: "created_at",
        name: "created_at",
        type: "datetime",
        required: true,
        isPrimary: false,
        autoIncrement: false,
        comment: "创建时间"
      }
    ]
  },
  {
    id: "departments",
    name: "departments",
    comment: "部门表",
    createdAt: "2025-01-01 10:00:00",
    updatedAt: "2025-01-10 16:20:00",
    fields: [
      {
        id: "id",
        name: "id",
        type: "number",
        required: true,
        isPrimary: true,
        autoIncrement: true,
        comment: "部门ID"
      },
      {
        id: "name",
        name: "name",
        type: "string",
        length: 100,
        required: true,
        isPrimary: false,
        autoIncrement: false,
        comment: "部门名称"
      },
      {
        id: "parent_id",
        name: "parent_id",
        type: "number",
        required: false,
        isPrimary: false,
        autoIncrement: false,
        comment: "上级部门ID",
        relation: {
          targetTableId: "departments",
          targetTableName: "departments",
          targetFieldId: "id",
          targetFieldName: "id",
          type: "many-to-one",
          enabled: true
        }
      },
      {
        id: "company_id",
        name: "company_id",
        type: "number",
        required: true,
        isPrimary: false,
        autoIncrement: false,
        comment: "公司ID",
        relation: {
          targetTableId: "companies",
          targetTableName: "companies",
          targetFieldId: "id",
          targetFieldName: "id",
          type: "many-to-one",
          enabled: true
        }
      },
      {
        id: "description",
        name: "description",
        type: "text",
        required: false,
        isPrimary: false,
        autoIncrement: false,
        comment: "部门描述"
      },
      {
        id: "created_at",
        name: "created_at",
        type: "datetime",
        required: true,
        isPrimary: false,
        autoIncrement: false,
        comment: "创建时间"
      }
    ]
  },
  {
    id: "companies",
    name: "companies",
    comment: "公司表",
    createdAt: "2025-01-01 10:00:00",
    updatedAt: "2025-01-05 09:15:00",
    fields: [
      {
        id: "id",
        name: "id",
        type: "number",
        required: true,
        isPrimary: true,
        autoIncrement: true,
        comment: "公司ID"
      },
      {
        id: "name",
        name: "name",
        type: "string",
        length: 200,
        required: true,
        isPrimary: false,
        autoIncrement: false,
        comment: "公司名称"
      },
      {
        id: "code",
        name: "code",
        type: "string",
        length: 50,
        required: true,
        isPrimary: false,
        autoIncrement: false,
        comment: "公司代码"
      },
      {
        id: "address",
        name: "address",
        type: "string",
        length: 500,
        required: false,
        isPrimary: false,
        autoIncrement: false,
        comment: "公司地址"
      },
      {
        id: "contact_info",
        name: "contact_info",
        type: "json",
        required: false,
        isPrimary: false,
        autoIncrement: false,
        comment: "联系信息"
      },
      {
        id: "founded_at",
        name: "founded_at",
        type: "date",
        required: false,
        isPrimary: false,
        autoIncrement: false,
        comment: "成立日期"
      }
    ]
  },
  {
    id: "orders",
    name: "orders",
    comment: "订单表",
    createdAt: "2025-01-02 11:00:00",
    updatedAt: "2025-01-20 18:45:00",
    fields: [
      {
        id: "id",
        name: "id",
        type: "number",
        required: true,
        isPrimary: true,
        autoIncrement: true,
        comment: "订单ID"
      },
      {
        id: "order_no",
        name: "order_no",
        type: "string",
        length: 50,
        required: true,
        isPrimary: false,
        autoIncrement: false,
        comment: "订单号"
      },
      {
        id: "user_id",
        name: "user_id",
        type: "number",
        required: true,
        isPrimary: false,
        autoIncrement: false,
        comment: "用户ID",
        relation: {
          targetTableId: "users",
          targetTableName: "users",
          targetFieldId: "id",
          targetFieldName: "id",
          type: "many-to-one",
          enabled: true
        }
      },
      {
        id: "total_amount",
        name: "total_amount",
        type: "number",
        required: true,
        isPrimary: false,
        autoIncrement: false,
        comment: "订单总金额"
      },
      {
        id: "status",
        name: "status",
        type: "string",
        length: 20,
        required: true,
        isPrimary: false,
        autoIncrement: false,
        defaultValue: "pending",
        comment: "订单状态"
      },
      {
        id: "created_at",
        name: "created_at",
        type: "datetime",
        required: true,
        isPrimary: false,
        autoIncrement: false,
        comment: "创建时间"
      }
    ]
  }
]

/** 模拟API接口配置 */
export const mockApiEndpoints: ApiEndpoint[] = [
  {
    id: "users-list",
    name: "获取用户列表",
    path: "/api/users",
    method: "GET",
    tableId: "users",
    tableName: "users",
    description: "获取用户列表，支持分页和筛选",
    enablePagination: true,
    enableSort: true,
    queryFields: [
      {
        fieldId: "username",
        fieldName: "username",
        tableId: "users",
        tableName: "users",
        operator: "like",
        required: false,
        enabled: true
      },
      {
        fieldId: "department_id",
        fieldName: "department_id",
        tableId: "users",
        tableName: "users",
        operator: "eq",
        required: false,
        enabled: true
      },
      {
        fieldId: "status",
        fieldName: "status",
        tableId: "users",
        tableName: "users",
        operator: "eq",
        required: false,
        enabled: true
      }
    ],
    responseFields: [
      {
        fieldId: "id",
        fieldName: "id",
        tableId: "users",
        tableName: "users",
        enabled: true
      },
      {
        fieldId: "username",
        fieldName: "username",
        tableId: "users",
        tableName: "users",
        enabled: true
      },
      {
        fieldId: "email",
        fieldName: "email",
        tableId: "users",
        tableName: "users",
        enabled: true
      },
      {
        fieldId: "name",
        fieldName: "department_name",
        tableId: "departments",
        tableName: "departments",
        alias: "department_name",
        enabled: true,
        relationPath: ["users.department_id", "departments.id"]
      }
    ]
  }
]

/** 模拟生成配置 */
export const mockGenerateConfig: GenerateConfig = {
  projectName: "人防门管理系统 Admin 后台接口文档",
  basePath: "/api/v1",
  version: "1.0",
  author: "系统管理员",
  description: "人防门管理系统是一款由 Spring Boot + Vue 3.2 + Vite 4.3 开发的新颖高效的企业级管理系统。",
  generateTypes: ["swagger", "typescript", "mock"]
}
